package com.fanrui.code.family;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;

import com.fanrui.code.dao.FamilyListDao;
import com.fanrui.code.db.jvmdb.IPersistable;
import com.fanrui.code.entity.Family;
import com.fanrui.code.entity.FamilyList;
import com.fanrui.code.player.Player;
import com.fanrui.code.player.PlayerDao;
import com.fanrui.code.player.PlayerManager;
import com.fanrui.proto.cmd.ClubItem;
import com.fanrui.proto.cmd.FamilyInfoCmd;
import com.fanrui.proto.cmd.FamilyJobPower;
import com.fanrui.proto.cmd.FamilyMemberInfoCmd;
import com.fanrui.proto.cmd.FamilySimpleInfoCmd;
import com.fanrui.proto.cmd.JoinPermission;
import com.fanrui.proto.cmd.MahjongBaseRoomConfig;
import com.fanrui.proto.cmd.PlayerInfoCmd;
import com.fanrui.proto.cmd.PlayersItem;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;

/**
 * 家族信息
 * */
public class FamilyEntity implements IPersistable<Integer>{
	
	private int id;
	/**
	 * 家族族长
	 * */
	private Player ower;
	
	/**
	 * 家族名称
	 * */
	private String familyName;
	
	/**
	 * 家族等级
	 * */
	private int familyLevel;
	
	/**
	 * 家族公告
	 * */
	private String familyNotice;
	
	/**
	 * 家族信息
	 * */
	private String familyInfo;
	
	/**
	 * 家族创建时间
	 * */
	private Date createTime;
	
	/**
	 * 家族成员
	 * */
	private Map<Long, FamilyMember> members = Collections.emptyMap();
	
	/**
	 * 申请列表
	 * */
	private Map<Long,Player> applyList = Collections.emptyMap();
	
	public Map<Long, Player> getExitList() {
		return exitList;
	}
	public void setExitList(Map<Long, Player> exitList) {
		this.exitList = exitList;
	}
	/**
	 * 退出列表
	 * */
	private Map<Long,Player> exitList = Collections.emptyMap();
	
	/**
	 * 家族动态列表
	 * */
	private List<FamilyTrends> trendsList = Collections.emptyList();
	
	/**
	 * 抽成统计
	 * */
	private AtomicLong familyDividend = new AtomicLong(0);
	
	/**
	 * 上级家族
	 * */
	private Integer superior;
	
	/**
	 * 状态
	 * */
	private Short status;
	
	public Short getStatus() {
		return status;
	}
	public void setStatus(Short status) {
		this.status = status;
	}
	/**
	 * 俱乐部已经创建的麻将房间
	 */
	volatile private List<MahjongBaseRoomConfig> mahjongConfigList = Collections.emptyList();
	
	public FamilyEntity() {
	}
	public FamilyEntity(Family family) {
		load(family);
	}
	public void load(Family family){
		this.id = family.getId();
		this.ower = PlayerManager.getInstance().findOrCreatePlayer(family.getFamilyOwer());
		this.familyName = family.getFamilyName();
		this.familyLevel = family.getFamilyLevel();
		this.familyNotice = family.getFamilyNotice();
		this.familyInfo = family.getFamilyInfo();
		this.createTime = family.getFamilyCreateTime();
		this.superior = family.getSuperior();
		this.status = family.getStatus();
		if(family.getDividend() != null){
			this.familyDividend.set(family.getDividend());
		}
		
		// 家族成员列表
		List<FamilyList> familyMembers = FamilyListDao.getInstance().getFamilyMember(family.getId());
		if(familyMembers != null && !familyMembers.isEmpty()) {
			members = new HashMap<Long, FamilyMember>();
			for(FamilyList fl : familyMembers) {
				FamilyMember familyMember = new FamilyMember(fl);
				if(familyMember.getPlayer() != null){
					members.put(familyMember.getPlayer().getId(),familyMember);
				}
			}
		}
		
//		// 加载俱乐部麻将房间
//		mahjongConfigList = new ArrayList<MahjongBaseRoomConfig>();
//		if(family.getMahjongRoomConfig() != null && !"".equals(family.getMahjongRoomConfig())) {
//			JsonArray membersJson = new JsonParser().parse(family.getMahjongRoomConfig()).getAsJsonArray();
//			if(membersJson != null && membersJson.size() > 0){
//				for (final JsonElement element : membersJson) {
//					MahjongBaseRoomConfig config = ChessTableManager.jsonToRoomConfigMj(element);
//					if(!mahjongConfigList.contains(config)) {
//						mahjongConfigList.add(config);
//					}
//				}
//			}
//		}
		
		
		// 加载俱乐部房间
//		if(family.getFamilyerList() != null && !"".equals(family.getFamilyerList())){
//			JsonArray membersJson = new JsonParser().parse(family.getFamilyerList()).getAsJsonArray();
//			if(membersJson != null && membersJson.size() > 0){
//				members = new HashMap<Long, FamilyMember>();
//				for (final JsonElement element : membersJson) {
//					FamilyMember familyMember = new FamilyMember(element);
//					
//					if(familyMember.getPlayer() != null){
//						members.put(familyMember.getPlayer().getId(),familyMember);
//						
//						// 一次性的
//						FamilyList fl = new FamilyList();
//						fl.setClubId(id);
//						fl.setPlayerId(familyMember.getPlayer().getId());
//						fl.setJointime(new Date(familyMember.getJoinTime()));
//						FamilyListDao.getInstance().insert(fl);
//					}
//				}
//			}
//		}
	
		//申请加入公会的玩家列表
		applyList = new HashMap<Long, Player>();
		if(family.getFamilyApplyList() != null && !"".equals(family.getFamilyApplyList())){
			JsonArray applyListJson = new JsonParser().parse(family.getFamilyApplyList()).getAsJsonArray(); 
			if(applyListJson != null && applyListJson.size() > 0){
				for (final JsonElement element : applyListJson) {
					long playerId = element.getAsLong();
					Player player = PlayerDao.getInstance().findById(playerId);
					if(player != null){
						applyList.put(playerId, player);
					}
				}
			}
		}
		
		//申请退出公会的玩家列表
		exitList = new HashMap<Long, Player>();
		if(family.getFamilyExitList() != null && !"".equals(family.getFamilyExitList())){
			JsonArray exitListJson = new JsonParser().parse(family.getFamilyExitList()).getAsJsonArray(); 
			if(exitListJson != null && exitListJson.size() > 0){
				for (final JsonElement element : exitListJson) {
					long playerId = element.getAsLong();
					Player player = PlayerDao.getInstance().findById(playerId);
					if(player != null){
						exitList.put(playerId, player);
					}
				}
			}
		}
		
		// 签到列表
//		if(family.getSiginInList() != null && !"".equals(family.getSiginInList())){
//			JsonArray signInList = new JsonParser().parse(family.getSiginInList()).getAsJsonArray(); 
//			if(signInList != null && signInList.size() > 0){
//				signList = new ArrayList<FamilySignInfo>();
//				Gson gson = new Gson();
//				for (final JsonElement element : signInList) {
//					FamilySignInfo signInfo = gson.fromJson(element, FamilySignInfo.class);
//					if(signInfo.getPlayerId() != null){
//						long playerId = signInfo.getPlayerId();
//						Player player = PlayerDao.getInstance().findById(playerId);
//						if(player != null){
//							signList.add(signInfo);
//						}
//					}
//					
//				}
//			}
//		}
		
		// 家族动态
//		if(family.getTrendsList() != null && !"".equals(family.getTrendsList())){
//			JsonArray trendsJsonList = new JsonParser().parse(family.getTrendsList()).getAsJsonArray(); 
//			if(trendsJsonList != null && trendsJsonList.size() > 0){
//				trendsList = new ArrayList<FamilyTrends>();
//				for (final JsonElement element : trendsJsonList) {
//					trendsList.add( new FamilyTrends(element));
//				}
//			}
//		}
	}

	public void save(){
		FamilyDao.getInstance().save(this);
	}
	
	public Integer getSuperior() {
		return superior;
	}
	public void setSuperior(Integer superior) {
		this.superior = superior;
	}
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public Player getOwer() {
		return ower;
	}

	public void setOwer(Player ower) {
		this.ower = ower;
	}

	public String getFamilyName() {
		return familyName;
	}

	public void setFamilyName(String familyName) {
		this.familyName = familyName;
	}

	public int getFamilyLevel() {
		return familyLevel;
	}

	public void setFamilyLevel(int familyLevel) {
		this.familyLevel = familyLevel;
	}

	public String getFamilyNotice() {
		return familyNotice;
	}

	public void setFamilyNotice(String familyNotice) {
		this.familyNotice = familyNotice;
	}

	public String getFamilyInfo() {
		return familyInfo;
	}

	public void setFamilyInfo(String familyInfo) {
		this.familyInfo = familyInfo;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Map<Long, FamilyMember> getMembers() {
		return members;
	}
	
	public FamilyMember getMemberByIdOrNickname(String idOrNickname) {
		if(members != null && !members.isEmpty() && idOrNickname != null) {
			for(FamilyMember fm : members.values()) {
				String id = fm.getPlayer().getId().toString();
				String name = fm.getPlayer().getNickname();
				if(idOrNickname.equals(id) || idOrNickname.equals(name)) {
					return fm;
				}
			}
		}
		return null;
	}
	
	public int getMemberSize() {
		return members.size();
	}

	public void setMembers(Map<Long, FamilyMember> members) {
		this.members = members;
	}

	public Map<Long, Player> getApplyList() {
		return applyList;
	}

	public void setApplyList(Map<Long, Player> applyList) {
		this.applyList = applyList;
	}
	
	/**
	 * 操作族长分红
	 * */
	public void operationDividend(long value){
		familyDividend.addAndGet(value);
		save();
	}
	
	/**
	 * 清零族长分红
	 * */
	public void clearDividend(){
		familyDividend.set(0);
	}
	
	/**
	 * 获取族长分红
	 * */
	public long getDividend(){
		return familyDividend.get();
	}
	

	/**
	 * 添加申请人到申请列表
	 * */
	public boolean addApplyToList(Player applyPlayer){
		for(Long playerId:applyList.keySet()){
			if(playerId.equals(applyPlayer.getId())){
				return false;
			}
		}
		applyList.put(applyPlayer.getId(), applyPlayer);
		save();
		return true;
	}
	
	/**
	 * 从申请人列表中移除
	 * */
	public void removeToApplyList(Player applyPlayer){
		if(applyList == null || !applyList.containsKey(applyPlayer.getId())){
			return;
		}
		applyList.remove(applyPlayer.getId());
	}
	
	/**
	 * 添加申请人到退出列表
	 * */
	public boolean addExitToList(Player applyPlayer){
		for(Long playerId:exitList.keySet()){
			if(playerId.equals(applyPlayer.getId())){
				return false;
			}
		}
		exitList.put(applyPlayer.getId(), applyPlayer);
		save();
		return true;
	}
	
	/**
	 * 从申请人列表中移除
	 * */
	public void removeToExitList(Player applyPlayer){
		if(exitList == null || !exitList.containsKey(applyPlayer.getId())){
			return;
		}
		exitList.remove(applyPlayer.getId());
	}
	
	/**
	 * 添加到公会成员中
	 * */
	public void addFamilyMember(Player member){
		for(Long playerId:members.keySet()){
			if(playerId == member.getId()){
				return;
			}
		}
		boolean isOwer = false;
		if(members == null || members.isEmpty()) {
			members = new HashMap<Long, FamilyMember>();
			members.put(member.getId(),new FamilyMember(member, true, this.getId()));
			return;
		}
		if(this.getOwer().getId() == member.getId()) {
			isOwer = true;
		}
		members.put(member.getId(),new FamilyMember(member, isOwer, this.getId()));
	}
	
	/**
	 * 从公会成员列表中移除
	 * */
	public void removeFormFamilyMemberList(FamilyMember member){
		if(members == null || !members.containsKey(member.getPlayer().getId())){
			return;
		}
		members.remove(member.getPlayer().getId());
		FamilyListDao.getInstance().delete(member.getPlayer().getId(), this.getId());
	}
	
	public boolean inFamily(long playerID){
		if(members == null || members.isEmpty()){
			return false;
		}
		return members.containsKey(playerID);
	}
	
	public FamilySimpleInfoCmd toSimpleInfo(){
		FamilySimpleInfoCmd.Builder builder = FamilySimpleInfoCmd.newBuilder();
		builder.setFamilylId(id);
		builder.setFamilyNotice(familyNotice);
		PlayerInfoCmd.Builder pBuilder = PlayerInfoCmd.newBuilder();
		pBuilder.setAccount(ower.getAccount());
		pBuilder.setGold(ower.getGold());
		pBuilder.setHeadIconUrl(ower.getHeadUrl());
		pBuilder.setInvitationCode(ower.getInvitationCode());
		pBuilder.setMoney(ower.getMoney());
		pBuilder.setNickname(ower.getNickname());
		pBuilder.setPlayerId(ower.getId());
		builder.setFamilyOwer(pBuilder.build());
		if(id == 10011){
			builder.setMemberNum(500);
		}else if((id == 10012)){
			builder.setMemberNum(386);
		}else{
			builder.setMemberNum(members.size());
		}
		builder.setFamilyName(familyName);
		builder.setCreateTime(createTime.getTime());
		return builder.build();
	}
	
	public ClubItem toClubItem(){
		ClubItem.Builder builder = ClubItem.newBuilder();
		builder.setId(id);
		builder.setCount(members.size());
		builder.setName(familyName);
		return builder.build();
	}
	
	public static Collection<FamilySimpleInfoCmd> toSimpleInfo(Collection<FamilyEntity> list){
		if(list !=null && !list.isEmpty()){
			ArrayList<FamilySimpleInfoCmd> result = new ArrayList<FamilySimpleInfoCmd>();
			for(FamilyEntity familyEnetify:list){
				result.add(familyEnetify.toSimpleInfo());
			}
			return result;
		}else{
			return Collections.emptyList();
		}
	}
	
	/**
	 * 转换成命令对象,家族转换成俱乐部
	 * @param list
	 * @return
	 */
	public static Collection<ClubItem> toClubItem(Collection<FamilyEntity> list){
		if(list !=null && !list.isEmpty()){
			ArrayList<ClubItem> result = new ArrayList<ClubItem>();
			for(FamilyEntity clubItem:list){
				result.add(clubItem.toClubItem());
			}
			return result;
		}else{
			return Collections.emptyList();
		}
	}
	
	public static List<PlayersItem> toClubPlayer(Map<Long, FamilyMember> map){
		if(map !=null && !map.isEmpty()){
			ArrayList<PlayersItem> result = new ArrayList<PlayersItem>();
			for(FamilyMember familyMember : map.values()){
				result.add(familyMember.toClubPlayers());
			}
			return result;
		}else{
			return Collections.emptyList();
		}
	}
	
	public FamilyInfoCmd toFamilyInfo(Long playerId){
		FamilyInfoCmd.Builder builder = FamilyInfoCmd.newBuilder();
		builder.setSimpleInfo(toSimpleInfo());
		builder.addAllMembers(FamilyMember.toMemberInfoCmds(members.values()));
		builder.addAllApplyList(PlayerManager.getInstance().playerToCmd(applyList.values()));
		builder.addAllQuiteList(PlayerManager.getInstance().playerToCmd(exitList.values()));
		PlayerInfoCmd.Builder pBuilder = PlayerInfoCmd.newBuilder();
		pBuilder.setAccount(ower.getAccount());
		pBuilder.setGold(ower.getGold());
		pBuilder.setHeadIconUrl(ower.getHeadUrl());
		pBuilder.setInvitationCode(ower.getInvitationCode());
		pBuilder.setMoney(ower.getMoney());
		pBuilder.setNickname(ower.getNickname());
		pBuilder.setPlayerId(ower.getId());
		builder.setOwer(pBuilder.build());
		builder.setMineInfo(FamilyMember.toMineInfoCmd(members.values(), playerId));
		if (status==0) {
			builder.setJoinPermission(JoinPermission.NoNeedToAgree);
		}else if(status==1){
			builder.setJoinPermission(JoinPermission.AdministratorAgrees);
		}else {
			builder.setJoinPermission(JoinPermission.RejectAll);
		}
		return builder.build();
	}
	
	public static Collection<FamilyInfoCmd> toFamilyInfo(Collection<FamilyEntity> list,Long playerId){
		if(list !=null && !list.isEmpty()){
			ArrayList<FamilyInfoCmd> result = new ArrayList<FamilyInfoCmd>();
			for(FamilyEntity familyEnetify:list){
				result.add(familyEnetify.toFamilyInfo(playerId));
			}
			return result;
		}else{
			return Collections.emptyList();
		}
	}
	
	public Family toFamily(){
		Family family = new Family();
		family.setId(id);
		family.setFamilyName(familyName);
		family.setFamilyOwer(ower.getId());
		family.setFamilyNotice(familyNotice);
		family.setFamilyLevel(familyLevel);
		family.setFamilyInfo(familyInfo);
		family.setDividend(familyDividend.get());
		family.setSuperior(superior);
		family.setFamilyCreateTime(createTime);
		family.setStatus(status);
		Gson gson = new Gson();
		if(members != null && !members.isEmpty()){
			
			// String json = gson.toJson(FamilyMember.toJsonArray(members.values()));
			family.setFamilyerList("");
			List<FamilyList> familyLists = new ArrayList<FamilyList>();
			for(FamilyMember fm : members.values()) {
				FamilyList fl = new FamilyList();
				fl.setClubId(id);
				fl.setPlayerId(fm.getPlayer().getId());
				fl.setJointime(new Date(fm.getJoinTime()));
				fl.setJob(fm.getJobId());
				fl.setClubIncome(fm.getClubIncome());
				familyLists.add(fl);
			}
			// 俱乐部成员更新到数据库
//			FamilyListDao.getInstance().updateClubMember(familyLists, id);
			
		}else{
			family.setFamilyerList(ower.getId()+"");
		}
		if(applyList != null && !applyList.isEmpty()){
			family.setFamilyApplyList(gson.toJson(applyList.keySet()));
		}else{
			family.setFamilyApplyList("");
		}
		if(exitList != null && !exitList.isEmpty()){
			family.setFamilyExitList(gson.toJson(exitList.keySet()));
		}else{
			family.setFamilyExitList("");
		}
		if(trendsList != null && !trendsList.isEmpty()){
			
			family.setTrendsList(FamilyTrends.listToJson(trendsList));
		}else{
			family.setTrendsList("");
		}
		
//		// 俱乐部房间
//		if(mahjongConfigList != null && !mahjongConfigList.isEmpty()) {
//			family.setMahjongRoomConfig(gson.toJson(mahjongConfigList));
//		}else {
//			family.setMahjongRoomConfig("");
//		}
//		if(sanZhangConfigList != null && !sanZhangConfigList.isEmpty()) {
//			family.setSanzhangRoomConfig(gson.toJson(sanZhangConfigList));
//		}else {
//			family.setSanzhangRoomConfig("");
//		}
		
		return family;
	}

	public List<FamilyTrends> getTrendsList() {
		return trendsList;
	}
	
	/**
	 * 根据玩家id查询家族成员
	 * @param player_id
	 * @return
	 */
	public FamilyMember getFamilyMemberById(long player_id) {
		return members.get(player_id)==null?null:members.get(player_id);
	}
	
	public Collection<FamilyMember> getAllFamilyMember(){
		return members.values();
	}
	
	/**
	 * 根据玩家名字匹配查询家族成员
	 */
	public List<FamilyMemberInfoCmd> getFamilyMemberByName(String player_name) {
		if(player_name!=null && !"".equals(player_name)) {
			List<FamilyMemberInfoCmd> memberList = new ArrayList<FamilyMemberInfoCmd>();
			for(FamilyMember member : members.values()) {
				if(member.getPlayer().getNickname().contains(player_name)) {
					memberList.add(member.toMemberInfoCmd());
				}
			}
			return memberList;
		}
		return null;
	}

	public synchronized void  addTrendsList(FamilyTrends familyTrends) {
//		if(trendsList==null || trendsList.isEmpty()){
//			trendsList = new ArrayList<>();
//		}
//		trendsList.add(familyTrends);
	}
	@Override
	public void setPersistKey(Integer id) {
		this.id = id;
	}
	@Override
	public Integer getPersistKey() {
		return id;
	}
	
	/**  
	*  检查玩家是否具备某种权限
	*  @param playerId
	*  @param jobPower
	*  @return    
	*  boolean    
	*/  
	public boolean checkJobPower(long playerId,FamilyJobPower jobPower){
		FamilyMember familyMember = getFamilyMemberById(playerId);
		if(familyMember == null){
			return false;
		}
		return familyMember.getFamilyJob().checkHavePower(jobPower);
	}
	
	/**  
	*  判断两个玩家的职位大小
	*  @param playerId
	*  @param jobPower
	*  @return    
	*  boolean    
	*/  
	public int checkJobPower(long playerId,long playerIdTwo){
		FamilyMember familyMember = getFamilyMemberById(playerId);
		FamilyMember familerMemerTwo = getFamilyMemberById(playerIdTwo);
		if(familyMember == null || familerMemerTwo == null){
			return -1;
		}
		
		return familyMember.getFamilyJob().compareTo(familerMemerTwo.getFamilyJob());
	}
	
	public List<MahjongBaseRoomConfig> getMahjongConfigList() {
		return mahjongConfigList;
	}
	public void setMahjongConfigList(List<MahjongBaseRoomConfig> mahjongConfigList) {
		this.mahjongConfigList = mahjongConfigList;
	}
	
//	/**
//	 * 添加麻将规则
//	 * */
//	public boolean addMahjongConfig(MahjongBaseRoomConfig config){
//		if(config != null) {
//			// 不能添加规则相同的
//			int mahjongType = config.getGaStyle().getAlgorithm() == 0 ? 0 : 1; // 成都和广安两种
//			int number = 0;
//			for(MahjongBaseRoomConfig c : mahjongConfigList) {
//				int cType = c.getGaStyle().getAlgorithm() == 0 ? 0 : 1;
//				if(cType == mahjongType) {
//					number++;
//				}
//			}
//			if(number >= 2) { // 同种麻将只能创建两个
//				return false;
//			}
//			for(MahjongBaseRoomConfig c : mahjongConfigList) {
//				if(ChessTableManager.isAlikeRoomConfig(config, c)) {
//					return false;
//				}
//			}
//			mahjongConfigList.add(config);
//			return true;
//		}
//		return false;
//	}
	
//	/**
//	 * 删除麻将规则
//	 * */
//	public void removeMahjongConfig(MahjongBaseRoomConfig config){
//		synchronized (mahjongConfigList) {
//			Iterator<MahjongBaseRoomConfig> iterator = mahjongConfigList.iterator();
//			while(iterator.hasNext()){
//				MahjongBaseRoomConfig c = iterator.next();
//				if(ChessTableManager.isAlikeRoomConfig(config, c)) {
//					iterator.remove();
//				}
//            }
//		}
//	}
//	
//	public void clearConfig() {
//		mahjongConfigList.clear();
//		sanZhangConfigList.clear();
//		save();
//	}
	
//	/**
//	 * 扣除创建俱乐部麻将房间的消耗
//	 * @param config
//	 * @return
//	 */
//	public boolean createClubRoomConsume(MahjongBaseRoomConfig config, boolean isCost) {
//		if (config != null) {
//			// 扣钱
//			int cost = MahjongHandle.getCost(config.getGaStyle().getBoardNum(),
//					config.getGaStyle().getAlgorithm());
//			if (isCost && this.getOwer().getCurrencyValue(com.fanrui.proto.cmd.CurrencyType.C_Money) < cost) {// 创建房间的消费不足
//				this.removeMahjongConfig(config);
//				save();
//				Stdout.GET().info("俱乐部【" + this.getId() + "】圈主砖石不足，无法创建！！！");
//				return false;
//			}
//			// 在俱乐部内创建房间
//			ITable table = ChessTableManager.getInstance().create(config, this.getId(),
//					this.getOwer().getId());
//			// 扣开房的钱
//			if(isCost) {
//				if (config.getMType() == com.fanrui.proto.cmd.MahjongGameType.Score
//						|| config.getMType() == com.fanrui.proto.cmd.MahjongGameType.ClubScore) {
//					PlayerData costPlayerData = new PlayerData(this.getOwer());
//					this.getOwer().operationCost(com.fanrui.proto.cmd.CurrencyType.C_Money, cost,
//							OperationType.Minus);
//					if (config.getMType() == com.fanrui.proto.cmd.MahjongGameType.Score) {
//						PlayerLogUtil.log(this.getOwer(), PlayerOpertionType.CreateFriendRoom,
//								((IPrivateChessTable<?, ?>) table).getNO(), this.getOwer().getId(), cost,
//								this.getId(), "创建俱乐部麻将积分房间", costPlayerData);
//					} else {
//						PlayerLogUtil.log(this.getOwer(), PlayerOpertionType.CreateFriendRoom,
//								((IPrivateChessTable<?, ?>) table).getNO(), this.getOwer().getId(), cost,
//								this.getId(), "创建俱乐部麻将计分房间", costPlayerData);
//					}
//					this.getOwer().save();
//				}
//			}
//			return true;
//		}
//		return false;
//	}
}
